package org.zoomdev.zoom.ioc;

import org.zoomdev.zoom.common.caster.Caster;
import org.zoomdev.zoom.common.config.ConfigReader;

import java.lang.reflect.Type;

public final class IocConfigKey extends IocKey {


    private final String file;

    public IocConfigKey(Type type, String name) {
        super(type, name);
        this.file = null;
    }


    public IocConfigKey(Type type, String name, String file) {
        super(type, name);
        this.file = file;
    }

    @Override
    public Object getValue(Ioc ioc) {

        Object v = ConfigReader.getDefault().getObject(getName(), file);
        return Caster.toType(v, getType());
    }


}
